{extend name="shop/default/Member/base" /}
{block name="resources"}
<!-- 添加css、字体文件文件 -->
<style type="text/css">
.find_con .stepflex_te dl{width:240px;}
.alert ul {overflow: hidden;}

.ncm-default-form h3 {
    font-weight: 600;
    line-height: 22px;
    color: #555;
    clear: both;
    background-color: #F5F5F5;
    padding: 5px 0 5px 12px;
    border-bottom: solid 1px #E7E7E7;
}
.ncm-default-form dl dt, .ncm-default-form dl dd {
    font-size: 12px;
    line-height: 32px;
    vertical-align: top;
    letter-spacing: normal;
    word-spacing: normal;
    text-align: right;
    display: inline-block;
    width: 14%;
    padding: 10px 1% 10px 0;
    margin: 0;
}
.ncm-default-form dl dd {
    text-align: left;
    width: 85%;
    padding: 10px 0 10px 0;
}
.ncm-default-form dl dt {
    width: 19%;
}
.ncm-default-form dl dd {
    width: 79%;
}
.ncm-default-form dl {
    font-size: 0;
    line-height: 20px;
    clear: both;
    padding: 0;
    margin: 0;
    border-bottom: dotted 1px #E6E6E6;
    overflow: hidden;
}
.bottom{
	text-align: center;
    margin-top: 19px;
}

.text{
	overflow: hidden;
    text-align: center;
}
.text>ul>li{
	clear: both;
}
</style>
{/block}
{block name="main"}

<div class="user-right"> 
	<div class="box">
 		<div class="tabmenu"><ul class="tab"><li class="active" id="tab1" >退款申请</li></ul></div>
 		
 		<div class="title"><h3>服务类型：退款</h3></div>
	    <div class="find_pw3">
	    	<div class="find_con">
	    		<div id="sflex04" class="stepflex stepflex_te">
		            <dl class="first doing">
		              <dt class="s-num">1</dt>
		              <dd class="s-text"> 买家申请退款<s></s> <b></b> </dd>
		            </dl>
		            {if condition="$detail.refund_status egt 2 or ($detail.refund_status lt 0 and $detail.refund_status gt -3)"}
		            	<dl class="normal doing">
		            {else /}
		            	<dl class="normal">
		            {/if}
		              <dt class="s-num">2</dt>
		              <dd class="s-text"> 商家处理退款申请<s></s> <b></b> </dd>
		            </dl>
		            
		            {if condition="$detail.refund_status egt 5 or ($detail.refund_status lt 0 and $detail.refund_status gt -3)"}
		            	<dl class="last doing">
		            {else /}
		            	<dl class="last">
		            {/if}
		              <dt class="s-num">&nbsp;</dt>
		              <dd class="s-text"> 退款完成 <s></s> <b></b> </dd>
		            </dl>
		         </div>
	    	</div>
	    </div>
	    
	    <div class=" ncm-default-form">
        <div id="warning"></div>
         
          {if condition="$detail.refund_status eq 0"}
          
            	{include file='shop/default/Member/controlRefundStatus0'/}
            	
          {elseif condition="$detail.refund_status eq -3" /}
          
          		{include file='shop/default/Member/controlRefundStatusNegative3'/}
          		
          {elseif condition="$detail.refund_status eq 1" /}
          
          		{include file='shop/default/Member/controlRefundStatus1'/}
          		
		  {elseif condition="$detail.refund_status eq 2" /}
		  
		  		{include file='shop/default/Member/controlRefundStatus2'/}
		  			
		  {elseif condition="$detail.refund_status eq 3" /}
			<div class="none-goods">
				<i class="icon-tip-circle"></i>
				<div class="text">
					<h4>等待商家收货</h4>
					<p>如果商家同意，退款申请将达成并退款至您的支付宝账号或银行卡中。</p>
				</div>
			</div>
			<div class="bottom">
            	<a href="javascript:history.go(-1);" class="main-btn main-btn-large">返回列表>></a>
            </div>
		  {elseif condition="$detail.refund_status eq 4" /}
			<!--等待卖家同意退款 begin-->
			
			<div class="wait-seller-agree">
				<i class="icon-tip-circle"></i>
				<div class="text">
					<h4>您已成功申请退款，等待卖家处理退款申请。</h4>
				</div>
			</div>
			<div class="bottom">
            	<a href="javascript:history.go(-1);" class="main-btn main-btn-large">返回列表>></a>
            </div>
			
			<!--等待卖家同意退款 begin-->
		  {elseif condition="$detail.refund_status eq 5" /}
			<!--step03 begin-->
			<div class="return-success">
				<i class="icon-right-circle"></i>
				<div class="text">
					<h4>退款成功</h4>
					<p class="time">卖家{$detail.refund_time | getTimeStampTurnTime}退款 {$detail.refund_real_money}元</p>
				</div>
			</div>
			<div class="bottom">
            	<a href="javascript:history.go(-1);" class="main-btn main-btn-large">返回列表>></a>
            </div>
		   {elseif condition="$detail.refund_status eq -1" /}
			<!--卖家拒绝 begin-->
			<div class="disagree-return">
				<i class="icon-tip-circle"></i>
				<div class="text">
					<h4>卖家拒绝您的退款申请</h4>
					<div class="operate"></div>
				</div>
			</div>
			<div class="bottom">
            	<a href="javascript:history.go(-1);" class="main-btn main-btn-large">返回列表>></a>
            </div>
			{elseif condition="$detail.refund_status eq -2" /}
			<div class="return-success">
				<i class="icon-tip-circle"></i>
				<div class="text">
					<h4>退款已关闭</h4>
				</div>
			</div>
			<div class="bottom">
            	<a href="javascript:history.go(-1);" class="main-btn main-btn-large">返回列表>></a>
            </div>
			{/if}
      </div>
	</div>     
</div>
{/block}

{block name="javascript"}
<script type="text/javascript">
var order_id = {$detail.order_id};
var order_goods_id ={$detail.order_goods_id};
$(function(){
	
	//如果退款原因是选择的其他就让用户自己写退款说明
	$("#refund_reason").change(function(){
		if($(this).val()=="其他")
		{
			$('#description_dl').show();
		}else{
			$('#description_dl').hide();
		}
	})
})
//添加退货信息物流
   function ExpressSave(){
        var LogisticsCompany=$("#LogisticsCompany").val();
        var ExpressNo=$("#ExpressNo").val();
        if(LogisticsCompany==""){
            $("#LogisticsCompany").focus();
            $.msg("物流公司不可为空");
        }else if(ExpressNo==""){
            $("#ExpressNo").focus();
            $.msg("运单号码不可为空");
        }else{
            $.ajax({
                url: "{:__URL('SHOP_MAIN/order/ordergoodsrefundexpress')}",
                type: "post",
                data: { "order_id": order_id, "order_goods_id": order_goods_id, "refund_express_company": LogisticsCompany, "refund_shipping_no": ExpressNo},
                dataType: "json",
                success: function (response) {
                	if(response.code>0){
                		window.location.reload();
                	}
                }
            });
         }
    }

//保存退款信息
function btnSave() {
    var refund_require = $("#refund_require").val();
    var refund_reason = $("#refund_reason").val();
    var refund_money = $("#refund_money").val();//退款金额
    var description = $("#description").val();//
    var maxRefundMoney = parseFloat($("#maxRefundMoney").val());
    if(isNaN(refund_money)){
    	$.msg("退款金额输入不合法");
    	$("#refund_money").select();
    	return false;
    }
    if(refund_money == ""){
    	refund_money = 0;
    }
    if(refund_money < 0 ){
    	$.msg("退款金额不能是负数");
    	$("#refund_money").select();
    	return false;
    }
    if (refund_money >maxRefundMoney) {
    	$("#refund_money").select();
    	$.msg("超出可退款金额范围");
    	return false;
    }
    if($('#refund_reason').val()=='其他'){
    	refund_reason=description;
    }
    $.ajax({
        url: "{:__URL('SHOP_MAIN/order/ordergoodsrefundaskfor')}",
        type: "post",
        data: {
        	"order_id": order_id, 
        	"order_goods_id": order_goods_id, 
        	"refund_type": refund_require, 
        	"refund_require_money":refund_money,
        	"refund_reason": refund_reason,
        },
        dataType:"json",
        success: function (response) {
         	if(response.code>0)
         	{
         		window.location.reload();
         	}else{
         		 $.msg(response.message);
         	}
        }
    })
}
</script>
{/block}